package com.swust.zj.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* @author 周杰
* @time 2017年9月1日 上午10:41:17
*/

@Configuration
@EnableWebMvc
@EnableSwagger2
@ComponentScan(basePackages = {"com.swust.zj.controller"})
public class Swagger2Config {
	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.swust.zj.controller"))
				.paths(PathSelectors.any())
				.build();
	}
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("RESTful API")
				.description("api url=http://localhost:8080/SSM_Template/v2/api-docs")
				.termsOfServiceUrl("http://localhost:8080/SSM_Template")
				.contact("周杰")
				.version("v1.0")
				.build();
	}
}
